/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package fallOutObjects;

import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.awt.geom.AffineTransform;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;

/**
 *
 * @author Windows7
 */
public class fallOutObjects implements fallOutObjectsInterface {
    
    protected String objectsImages;
    protected int x, y;
    protected BufferedImage img;
    protected boolean visible;
    
    protected int w;
    protected int h;
    
    protected final int Board_height = 540;
    protected int speed_missile;
    
    protected kindOfObject name;

    public kindOfObject getName() {
        return name;
    }

    public void setName(kindOfObject name) {
        this.name = name;
    }
    
    
    public enum kindOfObject
    {
        shit, egg, none;
    }
    
    public fallOutObjects(int i, int j, int speed) throws IOException
    {
        this.visible = true;
        this.x = i;
        this.y = j;
        this.speed_missile = speed;  
    }

    @Override
    public synchronized void draws(Graphics2D grap)
    {
        /*AffineTransform t = new AffineTransform();
        t.translate(this.x, this.y);
        t.scale(1, 1);*/
        grap.drawImage(this.img,this.x, this.y, null);
    }
    
    /**
     * @return the x
     */
    public int getX() {
        return x;
    }

    /**
     * @return the y
     */
    public int getY() {
        return y;
    }

    /**
     * @return the img
     */
    public BufferedImage getImg() {
        return img;
    }

    /**
     * @return the visible
     */
    public boolean isVisible() {
        return visible;
    }
    
    public boolean move()
    {
        boolean result = false;
        y += speed_missile;
        if(y >=  Board_height)
        {
            setVisible(false);
            if(this.name == kindOfObject.egg)
            {
                result = true;
            }
        }
        return result;
    }
    public Rectangle getBounds() {
        return new Rectangle(x - (this.w/4), y - (this.h/4), this.w/2, this.h/2);
    }

    /**
     * @param visible the visible to set
     */
    public void setVisible(boolean visible) {
        this.visible = visible;
    }

    
}
